home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 March / EnigmA AMIGA RUN 05 (1996)(G.R. Edizioni)(IT)[!][issue 1996-03][Skylink CD IV].iso / earcd / comm1 / kepmsg13.lha / KeepMsg.thor
Text File  |  1996-02-08  |  5KB  |  158 lines

  1. /*
  2. ** $VER: KeepMsg.thor 1.3a (8.2.95)
  3. ** by Eirik Nicolai Synnes <eirikns@sn.no>
  4. **
  5. ** Copies the current or selected message to a special "Keep" conference and
  6. ** sets the KEEP flag on them.
  7. **
  8. ** Specify the conference name in the toconf string below. If the conference
  9. ** doesn't exist it will be created.
  10. **
  11. ** If you don't want the copy in the destination conference to be marked as
  12. ** unread make sure nomarkmsg is set to 1 below. Otherwise set it to 0.
  13. **
  14. ** New in 1.3a:
  15. ** o Fixed a bug where the keep conference wouldn't be created if it didn't
  16. **   already exist
  17. */
  18.  
  19. toconf  = 'The Keep'
  20. nomarkmsg = 0
  21.  
  22. options results
  23. options failat 30
  24.  
  25. signal on syntax
  26. signal on halt
  27. signal on break_c
  28.  
  29. CDF_NOT_ON_BBS   = '00008000'x  /* This conference is not on the bbs. */
  30.  
  31. /* Open Thor and BBSREAD ARexx ports' */
  32.  
  33. p=address()||' '||show('P',,)
  34.     if pos('THOR.',p)>0 then thorport=word(substr(p,pos('THOR.',p)),1)
  35.     else do;say 'No THOR port found!'
  36.     exit(0)
  37.     end
  38.  
  39. if ~show('p', 'BBSREAD') then do
  40.     address command; "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
  41.     "WaitForPort BBSREAD"
  42.     if rc ~= 0 then do
  43.         address(thorport)
  44.         REQUESTNOTIFY '"Couldn''t open BBSRead''s ARexx port."' '"I see"'
  45.         exit(0)
  46.         end
  47.     end
  48.  
  49. address(thorport)
  50. trace off; CURRENTMSG curmsg; trace on
  51. if rc ~= 0 then do
  52.     REQUESTNOTIFY '"CURRENTMSG:\n'THOR.LASTERROR'"' '"Abort"'
  53.     exit(0)
  54.     end
  55.  
  56. GETMSGLISTSELECTED msgsel
  57. if rc = 3 | rc = 5 then do
  58.     msgsel.1 = curmsg.MSGNR; msgsel.COUNT = 1
  59.     end
  60. else if rc ~= 0 then do
  61.     REQUESTNOTIFY '"GETMSGLISTSELECTED:\n'THOR.LASTERROR'"' '"Abort"'
  62.     exit(0)
  63.     end
  64.  
  65. if msgsel.COUNT = 0 then do
  66.     REQUESTNOTIFY '"No selected messages."' '"Abort"'
  67.     exit(0)
  68.     end
  69.  
  70. address(bbsread)
  71. BUFMODE COPYBACK
  72.  
  73. do i = 1 to msgsel.COUNT
  74.     drop data. head. text.
  75.  
  76.     address(bbsread)
  77.     READBRMESSAGE '"'curmsg.BBSNAME'"' '"'curmsg.CONFNAME'"' '"'msgsel.i'"' TEXTSTEM text HEADSTEM head DATASTEM data
  78.     if rc ~= 0 then do
  79.         address(thorport)
  80.         REQUESTNOTIFY '"READBRMESSAGE (message #'msgsel.i'):\n 'BBSREAD.LASTERROR'"' '"Abort"'
  81.         signal cleanup
  82.         end
  83.  
  84.     if text.TEXT.COUNT = 0 & (text.PART.COUNT = 0 | symbol('text.PART.COUNT') ~= 'VAR') then do
  85.         address(thorport)
  86.         REQUESTNOTIFY '"No message body (message #'msgsel.i').\nMessage not copied."' '"'_Ok'"'
  87.         signal cleanup
  88.         end
  89.  
  90.     text.replyconf = curmsg.CONFNAME
  91.  
  92.     if head.fromname        ~= "HEAD.FROMNAME"        then text.fromname        = head.fromname
  93.     if head.fromaddr        ~= "HEAD.FROMADDR"        then text.fromaddr        = head.fromaddr
  94.     if head.toname          ~= "HEAD.TONAME"          then text.toname          = head.toname
  95.     if head.toaddr          ~= "HEAD.TOADDR"          then text.toaddr          = head.toaddr
  96.     if head.msgid           ~= "HEAD.MSGID"           then text.msgid           = head.msgid
  97.     if head.refid           ~= "HEAD.REFID"           then text.refid           = head.refid
  98.     if head.creationdate    ~= "HEAD.CREATIONDATE"    then text.creationdate    = head.creationdate
  99.     if head.creationdatetxt ~= "HEAD.CREATIONDATETXT" then text.creationdatetxt = head.creationdatetxt
  100.     if head.subject         ~= "HEAD.SUBJECT"         then text.subject         = head.subject
  101.  
  102.     red = ""; priv = ""; urg = ""; imp = ""; conf = ""
  103.     if bittst(data.flags, 0)  then red  = "READ"
  104.     if bittst(data.flags, 2)  then priv = "PRIVATE"
  105.     if bittst(data.flags, 11) then urg  = "URGENT"
  106.     if bittst(data.flags, 12) then imp  = "IMPORTANT"
  107.     if bittst(data.flags, 17) then conf = "CONFIDENTIAL"
  108.  
  109.     if nomarkmsg then nomark = 'DONTMARKMESSAGE'
  110.     else nomark = ''
  111.  
  112.     WRITEBRMESSAGE '"'curmsg.BBSNAME'"' '"'toconf'"' STEM text nomark red priv urg imp conf
  113.     if rc = 7 then do
  114.         CONFIGCONF '"'curmsg.BBSNAME'"' '"'toconf'"' SET c2x(CDF_NOT_ON_BBS)
  115.         WRITEBRMESSAGE '"'curmsg.BBSNAME'"' '"'toconf'"' STEM text nomark red priv urg imp conf
  116.         if rc ~= 0 then do
  117.             address(thorport)
  118.             REQUESTNOTIFY '"WRITEBRMESSAGE:\n'BBSREAD.LASTERROR'"' '"_Ok"'
  119.             signal cleanup
  120.             end
  121.         end
  122.     else if rc ~= 0 then do
  123.         address(thorport)
  124.         REQUESTNOTIFY '"WRITEBRMESSAGE:\n'BBSREAD.LASTERROR'"' '"_Ok"'
  125.         signal cleanup
  126.         end
  127.  
  128.     mnr = result
  129.     repl = ""
  130.     if bittst(data.flags, 1) then repl = "SETREPLIED"
  131.  
  132.     address(bbsread)
  133.     UPDATEBRMESSAGE '"'curmsg.BBSNAME'"' '"'toconf'"' mnr SETKEEP repl HAZELEVEL data.HAZELEVEL
  134.     if rc ~= 0 then do
  135.         address(thorport)
  136.         REQUESTNOTIFY '"UPDATEBRMESSAGE:\n'BBSREAD.LASTERROR'"' '"_Ok"'
  137.         signal cleanup
  138.         end
  139.     end
  140.  
  141. address(thorport)
  142. UPDATECONFWINDOW
  143.  
  144. signal cleanup
  145.  
  146. error:
  147. halt:
  148. break_c:
  149.  
  150. if rc ~= 0 then say '+++ Line 'sigl' returned 'rc': 'errortext(rc)
  151.  
  152. cleanup:
  153.  
  154. address(bbsread)
  155. BUFMODE ENDCOPYBACK
  156.  
  157. exit(0)
  158.